{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "c7ee70b9",
   "metadata": {},
   "source": [
    "# if条件判断"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "27d572c6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Work, work, work.\n"
     ]
    }
   ],
   "source": [
    "# 创建today变量(模块获取今天的星期几？)\n",
    "# 知识点： 1. 先创建变量，才能进行判断\n",
    "#          2. if语句 观察条件判断块的位置\n",
    "#          3. 按照条件块的间隙 找到归属关系\n",
    "\n",
    "today = \"Monday\"\n",
    "condition = \"good\"\n",
    "\n",
    "if today == \"Saturday\":\n",
    "    print(\"超开心\")  # if条件判断块\n",
    "elif today == \"Sunday\":\n",
    "    if condition == \"Headache\":\n",
    "        print(\"Recover, then rest.\")\n",
    "    else:\n",
    "        print(\"Rest.\")\n",
    "else:\n",
    "    print(\"Work, work, work.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "a1c90cc0",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'wday' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [2]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[43mwday\u001b[49m \u001b[38;5;241m!=\u001b[39m \u001b[38;5;241m1\u001b[39m: \u001b[38;5;66;03m# 判断是否是周二\u001b[39;00m\n\u001b[0;32m      2\u001b[0m     \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m今天没有Python课\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m      3\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m time_hour \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m12\u001b[39m \u001b[38;5;129;01mand\u001b[39;00m time_min \u001b[38;5;241m>\u001b[39m \u001b[38;5;241m50\u001b[39m:\n",
      "\u001b[1;31mNameError\u001b[0m: name 'wday' is not defined"
     ]
    }
   ],
   "source": [
    "if wday != 1: # 判断是否是周二\n",
    "    print(\"今天没有Python课\")\n",
    "elif time_hour == 12 and time_min > 50:\n",
    "    print(\"正在上Python课,刚上课\")\n",
    "elif time_hour == 13:\n",
    "    print(\"正在上Python课，大概第二节了\")\n",
    "elif time_hour == 14:\n",
    "    print(\"正在上Python课，妈呀，还在上，才2点\")\n",
    "elif time_hour == 15:\n",
    "    print(\"正在上Python课，坚持一下，快下课了！\")\n",
    "elif time_hour == 16 and time_min<50:\n",
    "    print(\"正在上Python课，最后一节课了，块下课啦\")\n",
    "else:\n",
    "    print(\"今天有Python课，上课时间是下午12.50-16.50\")\n",
    "    "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a660fb90",
   "metadata": {},
   "source": [
    "# for循环"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "6b41964f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2100001\n",
      "2100002\n",
      "2100003\n"
     ]
    }
   ],
   "source": [
    "# 自动生成学号\n",
    "for item in [1,2,3]:\n",
    "    print(item+2100000)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "9ab0261b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "#  range()自动生成想要的数值，可以控制for循环的次数，一个值，就是从0开始几个数\n",
    "for num in range(5):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "5524740d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "https://www.nfu.edu.cn/ztb/index0.htm\n",
      "https://www.nfu.edu.cn/ztb/index1.htm\n",
      "https://www.nfu.edu.cn/ztb/index2.htm\n",
      "https://www.nfu.edu.cn/ztb/index3.htm\n",
      "https://www.nfu.edu.cn/ztb/index4.htm\n",
      "https://www.nfu.edu.cn/ztb/index5.htm\n",
      "https://www.nfu.edu.cn/ztb/index6.htm\n",
      "https://www.nfu.edu.cn/ztb/index7.htm\n",
      "https://www.nfu.edu.cn/ztb/index8.htm\n",
      "https://www.nfu.edu.cn/ztb/index9.htm\n",
      "https://www.nfu.edu.cn/ztb/index10.htm\n",
      "https://www.nfu.edu.cn/ztb/index11.htm\n",
      "https://www.nfu.edu.cn/ztb/index12.htm\n",
      "https://www.nfu.edu.cn/ztb/index13.htm\n",
      "https://www.nfu.edu.cn/ztb/index14.htm\n",
      "https://www.nfu.edu.cn/ztb/index15.htm\n",
      "https://www.nfu.edu.cn/ztb/index16.htm\n",
      "https://www.nfu.edu.cn/ztb/index17.htm\n",
      "https://www.nfu.edu.cn/ztb/index18.htm\n",
      "https://www.nfu.edu.cn/ztb/index19.htm\n",
      "https://www.nfu.edu.cn/ztb/index20.htm\n",
      "https://www.nfu.edu.cn/ztb/index21.htm\n",
      "https://www.nfu.edu.cn/ztb/index22.htm\n",
      "https://www.nfu.edu.cn/ztb/index23.htm\n",
      "https://www.nfu.edu.cn/ztb/index24.htm\n",
      "https://www.nfu.edu.cn/ztb/index25.htm\n",
      "https://www.nfu.edu.cn/ztb/index26.htm\n"
     ]
    }
   ],
   "source": [
    "# for循环遍历案例 ： 某学校新闻网站数据URL队列获取\n",
    "\n",
    "# 中大南方-招投标- https://www.nfu.edu.cn/ztb/index.htm\n",
    "\n",
    "中大南方_招投标 = \"https://www.nfu.edu.cn/ztb/index.htm\"\n",
    "for page in range(27):\n",
    "    print(\"https://www.nfu.edu.cn/ztb/index\" + str(page) + \".htm\" )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4d76d2af",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
